using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Collections;
namespace SharePointUtility
{
    public partial class UploadForm : Form
    {
        public UploadForm()
        {
            InitializeComponent();
        }

        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                DocumentMigration documentMigration = new DocumentMigration();
                int loopCount = Convert.ToInt32(ConfigurationManager.AppSettings["LoopCount"]);
                int numberOfDocuments = Convert.ToInt32(ConfigurationManager.AppSettings["NumberOfDocuments"]);
                string[] year = Convert.ToString(ConfigurationManager.AppSettings["Year"]).Split(',');
                string moduleType = Convert.ToString(ConfigurationManager.AppSettings["ModuleType"]);
                for (int iYearCount = 0; iYearCount < year.Length; iYearCount++)
                {
                    for (int i = 1; i <= loopCount; i++)
                    {
                        documentMigration.UploadToSharepoint(numberOfDocuments, year[iYearCount], "H");
                    }
                    for (int i = 1; i <= loopCount; i++)
                    {
                        documentMigration.UploadToSharepoint(numberOfDocuments, year[iYearCount], "A");
                    }
                }

                MessageBox.Show("Upload Completed");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());

                string fileName = ConfigurationManager.AppSettings["ErrorLog"].ToString();
                System.IO.StreamWriter file = new System.IO.StreamWriter(fileName, true);
                file.WriteLine(ex.ToString());

                file.Close();
            }

        }
    }
}